package com.yeu;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBUtil {

	public static final String TABLE_PASSWORD = "table_user_password";
	public static final String TABLE_USER_INFO = "table_user_info";
	public static final String TABLE_USER_LOG = "table_user_log";
	public static final String TABLE_USER_COURSE = "table_user_course";
	public static final String TABLE_USER_TOPIC = "table_user_topic";
	public static final String TABLE_USER_TOPIC_REPLY = "table_user_topic_reply";
	public static final String TABLE_USER_ADVISE = "table_user_advise";
	public static final String KEY = "Llx970259858";//DES加密key
	public static String url = "jdbc:mysql://localhost:3306/yeu_school?useUnicode=true&characterEncoding=utf-8&useSSL=false";
	public static String user="root";
	public static String psd="970259858";
	
	//连接数据库
	public static Connection getConnect() {
		Connection connection = null;
		
		try {
			Class.forName("com.mysql.jdbc.Driver");//java反射，固定写法
			connection = DriverManager.getConnection(url,user,psd);
		} catch (ClassNotFoundException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO 自动生成的 catch 块
			System.out.println("SQLException:"+e.getMessage());
			System.out.println("SQLState:"+e.getSQLState());
			System.out.println("VendorError:"+e.getErrorCode());
		}
		return connection;
	}
	
}
